import { doGet, appJsonPost } from '@/network/request';
import axios from 'axios';


/**
 * 添加历史记录
 * @param {Number} resourceId - 资源ID
 * @param {Number} userId - 用户ID
 * @param {Number} historiesStatus - 历史记录状态
 * @param {String} createdTime - 创建时间
 */
export function addHistoryApi(resourceId, userId, historiesStatus) {
    const history = {
        resourceId,
        userId,
        historiesStatus
    };

    return appJsonPost({
        url: '/histories',
        data: history,

    });
}

/**
 * 删除历史记录
 * @param {Number} resourceId - 资源ID
 * @param {Number} userId - 用户ID
 * @param {Number} historiesStatus - 历史记录状态
 */
export function removeHistoryApi(resourceId, userId, historiesStatus) {
    return axios.delete(`/histories`, {
        params: { resourceId, userId, historiesStatus }, // 将参数作为请求参数传递

    });
}

/**
 * 查询用户的历史记录
 * @param {Number} userId - 用户ID
 */
export function getUserHistoryApi(userId: any) {
    return doGet({
        url: `/histories/list/${userId}`,
        params: { userId },

    });
}

/**
 * 检查用户是否观看某个资源
 * @param {Number} userId - 用户ID
 * @param {Number} resourceId - 资源ID
 */
export function checkUserHistoryApi(userId, resourceId) {
    return doGet({
        url: `/histories/check`,
        params: { userId, resourceId },

    });
}


/**
 * 查看某个资源的点赞总数
 * @param {Number} resourceId - 资源ID
 */
export function getHistoryCountApi(resourceId) {
    return doGet({
        url: `/histories/count`,
        params: { resourceId },

    });
}
